import { ref } from 'vue'
import { defineStore } from 'pinia'
import { genCaptchaApi } from '@/apis/captcha'

export const useCaptchaStore = defineStore('captcha', () => {
    const captchaConfig = ref({})

    const genCaptcha = async () => {
        let data = await genCaptchaApi()
        return data
    }

    const initConfig = (bgImageWidth, bgImageHeight, sliderImageWidth, sliderImageHeight, end) => {
        captchaConfig.value = {
            startTime: new Date(),
            trackArr: [],
            movePercent: 0,
            bgImageWidth,
            bgImageHeight,
            sliderImageWidth,
            sliderImageHeight,
            end
        }
    }
    
    return { captchaConfig, genCaptcha ,initConfig }
})